Efficient data transfer mechanism for input/output devices

ABSTRACT

A method for transferring data between non-contiguous buffers in a memory and an I/O device via a system I/O bus uses a descriptor queue stored in memory. Each descriptor points to a buffer and includes the length of the buffer. The I/O device is provided with the base address of the queue, the length of the queue and a current address which at initialization is the same as the base address. When data is to be transferred a device driver located in the processor sends the number of available descriptors (DescrEnq) to the I/O device which accesses the descriptors individually or in burst mode to gain access to the data buffers identified by the descriptors.

BACKGROUND

Field of the Invention

Advances in the design and fabrication of microprocessors in the past few years have resulted in a dramatic increase in processor speeds. In fact average speeds have increased more than four fold in the last decade alone. At the same time peripheral input/output busses have remained substantially constant. For example, the Industry Standard Architecture (ISA) bus operates at 8 MHz while many microprocessors operate in the 100-200 MHz range.

As the discrepancy in speed increases, it has become unfeasible to directly connect the I/O bus to the microprocessor. PC developers have solved this problem by providing "bridge modules" which disconnect the microprocessor/memory from the I/O bus. While this greatly improves the performance of the microprocessor when it is working from memory or cache, it typically does so at the expense of the microprocessor I/O bus interface. In the current PC environment it is typical for a microprocessor to wait 100 or more processor cycles for each I/O bus access.

Under these conditions the amount of time the microprocessor spends handling devices attached to the I/O bus can significantly impact the microprocessor's performance. Many high speed peripheral devices, such as disk drives and network controllers, are designed to be bus masters which allows these devices direct memory access (DMA). This removes the burden of data movement to the peripheral from the microprocessor resulting in an improvement in the utilization of the microprocessor bandwidth. However, microprocessor communication with peripheral devices still remains a major area for improvement.

A critical factor in the performance of today's computer systems is "I/O throughput". This refers to the ability of a computer system to quickly and efficiently move data between main memory and I/O devices.

FIG. 1 illustrates an environment in which the invention operates. High performance I/O devices generally operate as masters on the system bus for moving data from and to main memory. As bus masters, the I/O devices arbitrate for use of the system bus and directly write data to and read data from main memory. Operation of the I/O device is controlled by "device driver" software executing on the computer's main processor. The device driver monitors and controls the I/O devices by reading and writing their I/O registers across the system bus.

Improved I/O throughput can be achieved by making efficient use of the system bus. Improvements in efficiency appear possible in three areas:

1. reduce the number of register I/O write and read operations;

2. reduce I/O device data transfer overhead such as headers and control blocks; and,

3. utilize burst mode transfer capabilities.

SUMMARY OF THE INVENTION

The invention contemplates a method for transferring data between non-contiguous buffers in the memory and an I/O device. The driver defines a descriptor queue (DQ) in the memory having a base address (DescrBase) and an n descriptor capacity (DescrCount). At initialization the DescrBase, the DescrCount and a third value DescrCurrent, which at initialization equals the value of the DescrBase, are stored in the I/O device. The driver builds one or more descriptors in the DQ, each corresponding to a different one of the data buffers queued for transfer to the I/O device, the descriptors include at least the starting address of the buffer and a byte count. The number of descriptors built is stored in an enqueue (DescrEnq) register in the I/O device.

The I/O device examines the DescrEnq value for a non-zero condition and fetches a number of descriptors from the DQ corresponding to the DescrEnq value starting at the address specified by the DescrCurrent value and increments the DescrCurrent value and decrements the DescrEnq value each time a descriptor is fetched. The descriptors are used to read the memory and transfer the data read across the system bus for transmission.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of a system environment in which the invention operates.

FIG. 2 is a block diagram illustrating in detail the internal structure of the devices illustrated in FIG. 1.

FIG. 3 is an illustration of the device driver algorithm running on the processor illustrated in FIGS. 1 and 2.

FIG. 4 is an illustration of the data transfer state machine resident in the I/O device illustrated 4 in FIGS. 1 and 2.

DETAILED DESCRIPTION OF THE INVENTION

In FIG. 1 an I/O device 10 is connected to a main processor 11 and main memory 12 by a system bus 14 and a host bridge 15. The system bus may employ any one of a number of standard architectures such as PCI, ISA, etc. and the host bridge logic can use an Intel 430FX or similar devices provided by other manufacturers.

FIG. 2 illustrates elements within I/O device 10, processor 11 and memory 12 which are unique to the invention or interact with the unique elements.

Device driver software runs on the processor 11 (FIG. 3 is a flow diagram of the software). The memory 12 includes a number of data buffers 21 of varying size scattered throughout the memory. These buffers are used for storing data which is to be transferred to/from the I/O device. Typically, the I/O device could be a communications adapter for connecting the processor and its application programs to a communication network such as Token Ring, Ethernet, etc. and transmitting data generated and stored in the memory via the network. In addition to the data buffers, the memory includes a descriptor queue (Descr Queue) 22 and a status queue (Status Queue) 23.

The I/O device 10 includes system bus interface logic 24 which will conform to the specific requirements of the standard bus architecture selected for the application. A FIFO interface 25 which conforms to the specific requirements of the particular communication network selected for the application.

In addition the I/O device 10 includes a plurality (7) of registers 26 for storing information relative to the two queues 22 and 23 in the memory 12. The contents of these registers will be described in detail below. It also includes a storage area 27 for storing descriptors transferred from the queue 22 by a data transfer state machine 28 (FIG. 4 is a state diagram of machine 28).

Queues 22 and 23 each consist of a list of entries arranged in contiguous memory locations. Each is organized as a circular queue with processing of entries wrapping back to the top when the end of the list is reached. The device driver running on the processor establishes the location and number of entries in each of the queues by loading configuration registers 26 located in the I/O device at initialization time. Once configured the queues will remain static while the system is in operation.

Three configuration registers 26 are associated with each queue. For each queue one register holds the base address in main memory of the queue. A second holds a count of the number of entries or positions in the queue and a third defines the current position in the queue as it is processed. The seventh register contains a count which at all times indicates the number of data buffers 21 remaining to be processed.

Entries in the descriptor queue are created by the device driver software. Each descriptor entry typically includes:

1. a pointer (32 bits) to the physical address in main memory where the data buffer associated with that descriptor is located,

2. a byte count field (16 bits) which specifies the size of the associated data buffer, and

3. control information (up to 16 bits) to tell the I/O device how to handle the data transfer.

The data buffers defined by the descriptors in queue 22 can be either the source of data to be transmitted or the destination of data being received. In half duplex applications one set of queues 22 and 23 will suffice since only one function can take place at any given time. If full duplex operation is contemplated the queues 22 and 23 as well as the configuration registers 26 will have to be duplicated since both transmit and receive operations take place at the same time.

As data buffers are filled for transmission, the device driver software builds a descriptor for each buffer of data to be transmitted. These descriptors have the format described above. The driver then writes an "enqueue register"(DescrEnq register 26) on the I/O device. This write includes the number of descriptors built by the driver. The value is added by the I/O device to the current value of the DescrEnq register 26 (DER6) which indicates the number of descriptors (and buffers) ready for transmission.

When the DER26 has a non zero value, the data transfer machine 28 reads descriptors from the queue 22 starting at the DescrCurrent register 26 (DCuR26) value, which at initialization is equal to the DescrBase register 26 (DBR26). The DCuR26 and the DeserCount register 26 (DCoR26) enable the queues to operate as circular queues.

Each time a descriptor is read from the descriptor queue 22 register DCuR26 is incremented by one. A counter associated with register DCuR26 is also incremented by one each time a descriptor is read from the queue 22. Each time this counter is incremented the value is compared to the value stored in the DCoR26 register, if it is greater than the value stored a wrap is indicated and the value stored in the DBR26 register is entered in the DCuR26 register.

In those instances where more than one descriptor is to be fetched (a burst transfer) the number is added to the counter associated with the DCuR26 register and compared to the value stored in the DCoR26 register. If the value of the counter exceeds the value stored in the DCoR26 by more than one, the number of descriptor fetches must be reduced until the sum is equal to the value of the DCoR26 register plus one. On the access of the last descriptor the wrap completes as described above.

When the value of DER26 is greater than one, the state machine 28 can fetch a number of descriptors (up to the lesser of the value of the DER26 register, the storage capacity of the descriptor pre-fetch queue 27 or the limitation imposed by the wrap constraint described above) in burst mode thus reducing substantially the number of system bus accesses. The descriptors are stored in the descriptor pre-fetch queue 27 and processed via DMA/Bus Master protocol.

As the descriptors are fetched and the buffers transmitted, both the DCuR26 and the DER26 registers are updated to reflect the transmission of the data buffers. If, during the process, the device driver has additional data buffers to transmit, it builds additional descriptors and sends that number to the I/O device where it is added to the current value of the DER26 register.

As the data transfer state machine 28 (DTSM28) empties the data buffers 21 it builds buffer status information in the status queue 23 indicating the transmission of the data stored in the buffers. The DTSM28 uses the StatusBase register 26 (SBR26), the SatusCount register 26 (SCoR26) and the SatusCurrent register 26 (SCuR26) in the same way as the corresponding descriptor registers are used to determine where to place the status information concerning each of the data buffers transmitted in the status queue 23.

The receive mode is substantially similar to the transmit mode described above. In receive mode, however, the device driver loads the DER26 with the number of descriptors (buffers) available. The DBR26, DCoR26 and the DCuR26 registers are unchanged in operation. In receive mode the DTSM28 fetches descriptors from the descriptor queue 22 using the descriptor registers 26 as in the transmit mode and stores received data in the buffers indicated by the descriptors.

As the buffers are filled, the DTSM28 decrements the DER26 register and builds the status queue 23 using the status registers 26 in the same way it did in the transmit mode. The device driver checks the status queue and processes the received data in the buffers indicated in the status queue. As these buffers are emptied and become available to store additional data, the device driver sends the number of freed buffers across the system bus to the I/O device where the number is added to the current value of the DER26. Should the value of the DER26 fall to zero then an overrun error condition is indicated if received data must be transmitted to the data buffer.

The diagrams illustrated in FIGS. 3 and 4 are a convenient summary of the above detailed description and are self explanatory in view of that description. 

We claim:
 1. In a computer system having a processor, a memory and a system bus for connecting an input/output (I/O) device through a single channel I/O adapter to said memory and processor, a method for transferring data between non-contiguous buffers in the memory and the single channel I/O adapter comprising the steps:defining with a device driver a descriptor queue (DQ) in the memory having a base address (DescrBase) and an n descriptor capacity (DescrCount); at initialization using said device driver to store in the I/O device the DescrBase, the DescrCount and a third value DescrCurrent which at initialization equals the value of the DescrBase; building with the device driver one or more descriptors in the DQ, each corresponding to a different one of the data buffers, said descriptors including at least the starting address of the buffer and a byte count; adding the number of descriptors built to a descriptor enqueue (DescrEnq) value maintained at the I/O device; using a state machine to examine the DescrEnq value for a non-zero condition and fetching with said state machine a number of descriptors from the DQ corresponding to the DescrEnq value starting at the address specified by the DescrCurrent value and incrementing the DescrCurrent value and decrementing the DescrEnq value each time a descriptor is fetched; and using the state machine to read in memory and to transfer across the system bus the buffers specified by the fetched descriptors.
 2. In a computer system having a processor, a memory and a system bus for connecting an input/output (I/O) device to said memory and processor, a method for transferring data between non-contiguous buffers in the memory and the I/O device comprising the steps:defining a descriptor queue (DQ) in the memory having a base address (DescrBase) and an n descriptor capacity (DescrCount); at initialization storing in the I/O device the DescrBase and the DescrCount and storing a third value DescrCurrent which at initialization equals the value of the DescrBase; effecting transfer of data stored in one or more buffers in the memory to the I/O device by; building one or more descriptors in the DQ, each corresponding to a different one of the data buffers, said descriptors including at least the starting address of the buffer and a byte count, adding the number of descriptors built since last added to a descriptor enqueue (DescrEnq) value maintained at the I/O device; at the I/O device using a state machine to examine the DescrEnq value for a non-zero condition and fetching a number of descriptors from the DQ corresponding to the DescrEnq value starting at the address specified by the DescrCurrent value and incrementing the DescrCurrent value each time a descriptor is fetched and decrementing the DescrEnq value each time a descriptor is fetched; and using the state machine to read in memory and transferring across the system bus the buffers specified by the fetched descriptors.
 3. In a computer system having a processor, a memory and a system bus for connecting an input/output (I/O) device to said memory and processor, a method for transferring data between an I/O device and non-contiguous buffers in the memory comprising the steps:defining a descriptor queue (DQ) in the memory having a base address (DescrBase) and an n descriptor capacity (DescrCount); at initialization storing in the I/O device the DescrBase, the DescrCount and storing a third value DescrCurrent which at initialization equals the value of the DescrBase; building a number of descriptors in the DQ and loading a descriptor enqueue (DescrEnq) value at the I/O device indicating the number of descriptors built and available; examining by a state machine the DescrEnq value for a non-zero condition and fetching by the state machine during said non-zero condition descriptors as required from the DQ starting at the address specified by the DescrCurrent value and incrementing the DescrCurrent value and decrementing the DescrEnq value each time a descriptor is fetched; and transferring by the state machine across the system bus received data for storage in the buffers specified by the fetched descriptors.
 4. In a computer system having a processor including an input/output (I/O) device driver, a memory, host bridge logic and a system bus for connecting an (I/O) device to said memory and processor via said host bridge logic, a method for transferring data between non-contiguous buffers in the memory and the I/O device comprising the steps:defining a descriptor queue (DQ) in the memory having a base address (DescrBase) and an n descriptor capacity (DescrCount); at initialization storing in the I/O device the DescrBase and the DescrCount and storing a third value DescrCurrent which at initialization equals the value of the DescrBase; building a number of descriptors in the DQ, each corresponding to a different one of the data buffers, said descriptors including at least the starting address of the buffer and a byte count and loading a descriptor enqueue (DescrEnq) value at the I/O device indicating the number of descriptors built and available; at the I/O device using a state machine to examine the DescrEnq value for a non-zero condition and fetching during said non-zero condition descriptors as required from the DQ starting at the address specified by the DescrCurrent value and incrementing the DescrCurrent value and decrementing the DescrEnq value each time a descriptor is fetched; and using the state machine to transfer across the system bus received data for storage in the buffers specified by the fetched descriptors.
 5. The method set forth in any one of claims 1-4 including the steps:using the state machine to count the number of descriptor fetches; and, using the state machine to change the DescrCurrent value to the DescrBase value when the number of descriptor fetches exceeds the DescrCount value.
 6. A device driver comprising:a substrate on which a computer program is recorded, said computer program including a first code module that builds a stack of N descriptors, wherein N≧1 and each descriptor describes a data buffer; a second code module that writes N in a register; a third code module that increments a pointer from a first position to a tail position in said stack; and a fourth code module that monitors a selected position of a status queue to detect a predetermined condition.
 7. The device driver of claim 6 further including a fifth code module that processes data in said data buffer if the predetermined condition includes a non-zero integer.
 8. The device driver of claim 7 wherein the fifth code module returns the data buffers, from which data as been processed, to a free buffer pool.
 9. The device driver of claim 6 further including a sixth code module that resets the non-zero integer to zero after the data in said data buffer has been processed.
 10. The device driver of claim 9 further including a seventh code module that increments a printer associated with the status queue from a last process position to a current position whereat processing is to begin.
 11. A controller for transferring data between a host system and external devices that are connected to the network controller the host system having memory with data buffers, a descriptor queue and a receive status queue, the controller comprising:a first register that maintains a number of descriptors that are currently available in the descriptor queue for use in a direct memory access (DMA) transfer; a second register that maintains an address of the location of the first descriptor of the currently available descriptors in the descriptor queue; a buffer for temporarily storing currently available descriptors that are obtained from the descriptor queue; and hardware circuitry that controls obtaining the currently available descriptors from the descriptor queue for temporary storage in the descriptor FIFO, the circuitry retrieving as many currently available descriptors as possible to fill the descriptor FIFO, based on the number in the first register and the address in the second register.
 12. The controller of claim 11 wherein the hardware circuitry includes a state machine.
 13. The controller of claim 12 wherein the state machine decrements the number of said first register by a value equal to the number of descriptors removed from said descriptor queue by the state machine.
 14. A network interface card comprising:a single channel operatively coupling said card to at least one device; a first register that holds a base address whereat a descriptor queue is located in a memory; a second register that holds a count indicating the number of entries in the descriptor queue; a storage that stores descriptors transferred from the descriptor queue; and a state machine that controls transferring currently available descriptors from the descriptor queue for temporary storage in the storage wherein the number of descriptors transferred is based upon the number in the second register and the address in the first register.
 15. The controller of claim 11 or the network interface card of claim 14 further including a third register that holds an address indicating the current position in the queue whereat processing is being done.
 16. The controller of claim 11 or the network interface card of claim 14 further including:a status base register that holds a base address whereat a status queue is located in memory; a status count register that holds a count representative of the number of entries in the status queue; and a status current register holding an address indicating a current position in said status register whereat processing is being done.
 17. A host system comprising:a memory; a plurality of data buffers that store data distributed throughout said memory; a device driver that generates a descriptor queue containing entries identifying locations of data buffer and actions to be taken relative to data in said buffers; and a status queue that holds information regarding actions done to data in said registers wherein said device driver monitors the status queue and return buffers to a free buffer pool based upon a predetermined condition detected at said status queue.
 18. A data transfer mechanism for use in a computer comprising:a memory; a descriptor queue position in said memory; a device driver that generates and loads entries in said descriptor queue, said entries at least indicating locations whereat data buffers are located in the memory; a single channel adapter; a bus operatively coupling the single channel adapter to the memory; a descriptor base address register positioned in the adapter; a descriptor count register positioned in the adapter; a descriptor current address register positioned in the adapter; a descriptor enqueue register positioned in the adapter wherein each of the registers is loaded with control information by said device driver at an initialization period; a memory, in said adapter, that temporarily stores descriptors; and a state machine that accesses selected ones of the registers and transfer descriptors from the descriptor queue to the memory based upon information contained in said selected ones of the registers.
 19. The data transfer mechanism of claim 18 wherein the state machine further causes data to be transferred from the adapter across the bus into the data buffers or from the data buffers across the bus into the adapter. 